Skip to content

Conversation

@deepika-awasthi
Copy link

Fix pydantic validation errors bypassing interceptor layer

Summary

This PR fixes an issue where pydantic validation errors during argument decoding were bypassing the interceptor layer because they occurred in the data converter and were not properly caught by the existing error handling.

The core change modifies CompositePayloadConverter.from_payloads method to catch pydantic ValidationError exceptions and wrap them as RuntimeError, ensuring they follow the same error handling path as other conversion errors. This allows them to be properly caught by the existing workflow_is_failure_exception logic and configured as workflow failures when appropriate.

Key Changes:

  • Added exception handling in CompositePayloadConverter.from_payloads to detect and wrap pydantic ValidationError
  • Added comprehensive tests for both workflow and activity pydantic validation error scenarios
  • Maintains backward compatibility with existing error handling for non-pydantic errors

Review & Testing Checklist for Human

  • Verify string-based pydantic error detection is robust - The fix uses module name and class name matching to identify pydantic ValidationErrors. Test with different pydantic versions to ensure this detection method remains reliable.
  • Run existing pydantic test suite - Ensure tests/contrib/pydantic/ and related tests still pass to verify no regressions were introduced.
  • Test activity validation error path - The activity test may not properly trigger validation errors since it passes {"bar": 123} to an activity expecting Foo(bar: str). Manually verify that pydantic validation errors in activities are now properly handled.
  • End-to-end validation - Create a real workflow/activity with pydantic validation, trigger validation errors, and confirm they're now caught by interceptors and can be configured as failure exceptions rather than causing "Failed decoding arguments" logs.

Notes

This PR addresses the issue described in the original report where pydantic validation errors were generating "Failed decoding arguments" logs because they bypassed the interceptor layer. The solution is conservative and maintains existing behavior for all non-pydantic exceptions.

Link to Devin run: https://app.devin.ai/sessions/a3666eda1d1a47d0a389cbe3e2843829
Requested by: @deepika-awasthi

- Modify CompositePayloadConverter.from_payloads to catch pydantic ValidationError
- Wrap pydantic validation errors as RuntimeError for consistent handling
- Add comprehensive tests for both workflow and activity scenarios
- Maintain backward compatibility with existing error handling

This ensures that pydantic validation errors are properly caught by the
existing workflow_is_failure_exception logic and can be configured as
workflow failures when appropriate.

Co-Authored-By: deepika awasthi <[email protected]>
@deepika-awasthi deepika-awasthi requested a review from a team as a code owner September 29, 2025 17:04
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@deepika-awasthi deepika-awasthi deleted the devin/1759165209-fix-pydantic-validation-errors branch September 29, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants